// Created by liusc on 2020/7/28--11:17.
import sortTree from '@/components/sort-tree'
import {mapGetters} from "vuex"
import {fetchList2} from "@/views/wy-budget/api/budgetinitiate.js";
import budgetSummaryDetail from "~/views/wy-budget/budget-summary/form/detail.vue"

export default {
    name: 'resource-manage',
		provide () {
			return {
				initList: this.getListData
			};
		},
    components: {
        sortTree,
        budgetSummaryDetail: budgetSummaryDetail
    },
    data() {
        return {
            tableData: [],
            get_button: false,
						// 请求参数
						params: {
							current: 1,
							size: 20,
							budgetCode: ""
						},
						// 分页
						pager: {
							total: 0, // 总页数
							current: 1, // 当前页数
							size: 20 // 每页显示多少条
						},
        }
    },

    computed: {
        ...mapGetters(['permissions']),
    },

    mounted() {
        this.get_button = this.permissions['summary_get']
				this.getListData();
    },

    methods: {
				getListData (params = {}) {
					this.loading = true;
					let requestData = { ...this.params, ...params };
					fetchList2(requestData)
						.then(res => {
							const { current, size, total, records } = res.data.data;
							this.tableData = records;
							this.params = requestData;
							this.pager = { total, current, size };
						})
						.finally(() => {
							this.loading = false;
						});
				},
        toLookData(scope) {
            this.$refs.budgetSummaryDetail.show(scope.row);
        },

    }
}
